/*  倒计时  */
var _timer;
function fnTimeCountDown(dur) {
    if(typeof(worker)==="undefined") {
        worker = new Worker("../test_worker.js");
        worker.postMessage(dur);

        worker.onmessage = function (event) {
            var info = event.data;
            if(parseInt(info)<=0){
                try {
                    $('#overTime').empty().hide();
                    reFresh(window.auth);
                }catch (e) {
                    console.log(e)
                }
                worker.terminate();
            }else{
                var i = Math.floor(info / 3600 % 24),
                    j = Math.floor(info / 60 % 60),
                    k = Math.floor(info % 60);
                i = i < 10 ? "0" + i : i, j = j < 10 ? "0" + j : j, k = k < 10 ? "0" + k : k;
                $('#timer-wrapper').html(i+':'+j+':'+k);
            }
        }
    }else{
        worker.terminate();
        worker = new Worker("../test_worker.js");
        worker.postMessage(dur);

        worker.onmessage = function (event) {
            var info = event.data;
            if(parseInt(info)<0){
                try {
                    reFresh(window.auth);
                }catch (e) {
                    console.log(e)
                }
                worker.terminate();
            }else{
                var i = Math.floor(info / 3600 % 24),
                    j = Math.floor(info / 60 % 60),
                    k = Math.floor(info % 60);
                i = i < 10 ? "0" + i : i, j = j < 10 ? "0" + j : j, k = k < 10 ? "0" + k : k;
                $('#timer-wrapper').html(i+':'+j+':'+k);
            }
        };
    }
    /*var worker = new Worker('../test_worker.js');
    worker.postMessage(dur);

    worker.onmessage = function (event) {
        var info = event.data;
        var i = Math.floor(info / 3600 % 24),
            j = Math.floor(info / 60 % 60),
            k = Math.floor(info % 60);
        i = i < 10 ? "0" + i : i, j = j < 10 ? "0" + j : j, k = k < 10 ? "0" + k : k;
        $('#timer-wrapper').html(i+'时'+j+'分'+k+'秒');
    }*/
    /* var f = {
         zero: function (n) {
             var m = parseInt(n, 10);
             if (m > 0) {
                 if (m <= 9) {
                     n = "0" + m;
                 }
                 return String(n);
             } else {
                 return "00";
             }
         },
         dv: function () {
             // d = d || Date.UTC(2050, 0, 1);
             /!*var future = new Date(d),
                 now = new Date();*!/
             dur--;

             // 获取 当前时间与活动时间 时间差（单位：s）
             var /!*dur = Math.round((future.getTime() - now.getTime()) / 1000+1) + future.getTimezoneOffset() * 60,*!/
                 pms = {
                     sec: "00",
                     min: "00",
                     hour: "00",
                     day: "00",
                     month: "00",
                     year: "0"
                 };
             if (dur > 0) {
                 // 获取秒
                 pms.sec = f.zero(dur % 60);
                 // 获取分钟
                 pms.min = Math.floor((dur / 60)) > 0 ? f.zero(Math.floor((dur / 60)) % 60) : "00";
                 // 获取小时
                 pms.hour = Math.floor((dur / 3600)) > 0 ? f.zero(Math.floor((dur / 3600)) % 24) : "00";
                 // 获取天
                 pms.day = Math.floor((dur / 86400)) > 0 ? f.zero(Math.floor((dur / 86400)) % 30) : "00";
                 // 获取月
                 pms.month = Math.floor((dur / 2629744)) > 0 ? f.zero(Math.floor((dur / 2629744)) % 12) : "00";
                 // 获取年
                 pms.year = Math.floor((dur / 31556926)) > 0 ? Math.floor((dur / 31556926)) : "0";
             }
             return pms;
         },
         ui: function () {
             var par = f.dv();
             // for (var i in o) {
             //     o[i].innerHTML = par[i];
             // }
             $('#timer-wrapper').html(par.hour+':'+par.min+':'+par.sec);
             f.loop();
         },
         loop: function () {
             if (_timer) clearTimeout(_timer);
             _timer = setTimeout(f.ui, 1000);
         }
     };
     f.ui();*/
}